public class Box {
    private  int milke;
    private   Boolean state=false;
    public synchronized  void  put(int milke){
        if(state){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        this.milke=milke;
        System.out.println("存入的奶瓶数是"+this.milke+"瓶");
        state =true;
        notifyAll();

    }
    public synchronized void get(){
        if(!state){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        this.milke=milke;
        System.out.println("消费者取出的奶瓶数是："+this.milke+"瓶");
        state =false;
        notifyAll();
    }
}
